﻿using System.Data;
using ET;

namespace DAL
{
    public class Department_DAL
    {
        private readonly clsConnect cls = new clsConnect();
        #region Getdata
        public DataTable BindGirdtb_Department(string keywords)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@KEYWORDS", keywords);
            return cls.GetData("sp_tb_Department_Search");
        }
        public DataTable GetDataEdit(int id)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Department_Id", id);
            return cls.GetData("sp_tb_Department_Edit");
        }
        #endregion

        #region[Insert-Update-Delete]
        public bool Inserttb_Department(Department_ET data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Department_Alias", data.Department_Alias);
            cls.AddParameter("@Department_Name", data.Department_Name);
            cls.AddParameter("@Department_Note", data.Department_Note);
            cls.AddParameter("@Department_User_Add", data.Department_User_Add);
            cls.AddParameter("@Department_Date_Add", data.Department_Date_Add);
            cls.AddParameter("@Department_Computer_Add", data.Department_Computer_Add);
            return cls.ExecuteNonQuery("sp_tb_Department_Insert");
        }
        public bool Updatetb_Department(Department_ET data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Department_Id", data.Department_Id);
            cls.AddParameter("@Department_Alias", data.Department_Alias);
            cls.AddParameter("@Department_Name", data.Department_Name);
            cls.AddParameter("@Department_Note", data.Department_Note);
            cls.AddParameter("@Department_User_Modify", data.Department_User_Modify);
            cls.AddParameter("@Department_Date_Modify", data.Department_Date_Modify);
            cls.AddParameter("@Department_Computer_Modify", data.Department_Computer_Modify);
            return cls.ExecuteNonQuery("sp_tb_Department_Update");
        }
        public bool Deletetb_Department(int id)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Department_Id", id);
            cls.ExecuteNonQuery("sp_tb_Department_Delete");
            return true;
        }
        #endregion
    }
}
